<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/common.jspf" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>商品管理</title>
</head>

<script type="text/javascript">
    $(function (){
        $('#dg').datagrid({
            url:'${proPath}/seeshop/sees.action', // user/select.action
            // method:'post',
            //idfield:'productid',
            columns:[[
                {checkbox:true},
                {field:'headOffice',title:'总公司',width:100},
                {field:'showName',title:'店铺名称',width:100},
                {field:'files',title:'商品图片',width:100,
                    formatter:function (value,row,index) {
                      if(value!=null){
       return  "<img src='${proPath}/upload/"+value+"' style='width: 40px; height: 40px;'>";
                                                }
                }},
                {field:'shopNumber',title:'店铺编号',width:100},
                {field:'shopName',title:'商品名称',width:100},
                {field:'shopCase',title:'商品状态',width:100},
                {field:'shopPrice',title:'商品价格',width:100},
                {field:'shopType',title:'商品分类',width:100,align:'right'}
            ]],
            fitColumns:true,
            toolbar: [{
                iconCls: 'icon-save',
                text:'添加',
                handler: function(){
                    alert('添加');
                    parent.$('#win').window({
                        width:1000,
                        height:500,
                        title:'添加商品',
                        modal:true,
                        content:"<iframe src='${proPath}/base/goURL.action?url=shop/adddShop' title='添加用户' height='100%' width='100%' frameborder='0px'/>"
                    });
                }
            },'-',{
                iconCls: 'icon-edit',
                text:'修改',
                handler: function(){
                    //获取当前点击的商品，返回是一个数组
                    var array = $('#dg').datagrid("getSelections");

                    if(array.length<1){
                        //alert("请选择需要修改的商品");
                        $.messager.alert('警告','请选择需要修改的商品','info');
                        return ;
                    }
                    if(array.length>1){
                        //alert("只能选择需要一个修改商品");
                        $.messager.alert('警告','只能选择需要一个修改商品','info');
                        return ;
                    }
                    parent.$('#win').window({
                        width:1000,
                        height:500,
                        title:'修改商品',
                        modal:true,
                        content:"<iframe src='${proPath}/base/goURL.action?url=shop/AmendShop' title='修改商品' height='100%' width='100%' frameborder='0px'/>"
                    });
                }
            },'-',{
                iconCls: 'icon-remove',
                text:'删除',
                handler: function(){
                  var array = $("#dg").datagrid("getSelections");
                  var arr="";
                  for(var i=0;i<array.length;i++){
                      arr+=array[i].shopId+",";
                  }
                    if(array.length<1){
                        $.messager.alert('警告','请选择需要删除的商品','info');
                        return ;
                    }
                    if(array.length>=1){

                        $.messager.confirm('警告', '是否确定删除商品', function(r){
                            if (r){
                                $.post(
                                    "${proPath}/seeshop/delete.action",
                                    {s:arr},
                                    function (json) {
                                        if(json!=0){
                                            //刷新原页面
                                            $('#dg').datagrid("reload");
                                        }
                                    },
                                    "json"
                                );
                            }
                        });
                        return ;
                    }
                }
            }],
            striped:true,
            rownumbers:true,
            pagination:true,
            pageSize:5,
            pageList:[5,10,15,20,25],
            /* queryParams: {
             userName: 'easyui',
             userAddress: 'datagrid'
             } */
        });
    });


    function deman() {

     $(function () {
            var showName = $("#showName").val();
            var shopName = $("#shopName").val();
            var shopCase = $("#shopCase").val();
            var shopNumber = $("#shopNumber").val();
            var total =  showName + shopName + shopCase + shopNumber ;



             $('#dg').datagrid('load', {
                 showName: showName,
                 shopNumber: shopNumber,
                 shopName: shopName,
                 shopCase: shopCase
             });
        });
    }

</script>
<body>
<form action="" method="post" id="xx">
    总公司 ：
    <select  class="headOffice" name="dept" style="width:100px;"  id="headOffice">
        <option value="aa">宏福</option>
    </select>
    店铺名称：
    <input  style="width:100px;" type="text" id="showName" name="showName">
    </input>
    商品名称：
    <input type="text" name="shopName" style="width:100px;" id="shopName">
    商品编号：
    <input type="text" name="shopNumber" style="width:100px;" id="shopNumber">
    商品状态：
    <select  class="easyui-combobox" name="shopCase" style="width:100px;" id="shopCase">
        <option ></option>
        <option>上架</option>
        <option>下架</option>
    </select>
    <input type="button" value="查询" onclick="deman()" >
</form>

<table id="dg" ></table>

</body>
</html>